package com.taxshare.purchaser.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taxshare.mybatis.pager.PageHelp;
import com.taxshare.mybatis.pager.PageInfoRequest;
import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.purchaser.entity.InvoiceCollectionsEntity;
import com.taxshare.purchaser.mapper.InvoiceCollectionsMapper;
import com.taxshare.purchaser.view.dto.InvoiceCollectionsDTO;
import com.taxshare.response.beans.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
public class InvoiceCollectionsService extends ServiceImpl<InvoiceCollectionsMapper, InvoiceCollectionsEntity> {
    @Autowired
    CommService commService;
    /**
     * 查询
     *
     * @param dto
     * @return
     */
    public Response invoiceCollectionsQuery(PageRequest<InvoiceCollectionsEntity> query) {
        InvoiceCollectionsEntity invoiceCollections = query.getInfo();
        QueryWrapper<InvoiceCollectionsEntity> queryWrapper = new QueryWrapper();
        if (StrUtil.isNotBlank(invoiceCollections.getFphm())) {
            queryWrapper.eq("fphm", invoiceCollections.getFphm());
        }
        queryWrapper.orderByDesc("kprq");
        IPage<InvoiceCollectionsEntity> result = PageHelp.siamplePage(this, queryWrapper, query.getPage(), InvoiceCollectionsEntity.class);
        return Response.success(result);
    }

}
